package InputStream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.ObjectInputStream;

/**
 * @author 王艺锡
 * @version 1.0
 * 对象流，处理流
 * ObjectInputStream
 * 可以读取数据和数据类型
 */
public class ObjectInputStream_ {
    public static void main(String[] args) throws Exception {
        String filePath = "e:\\data.txt";
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filePath));

        //读取
        //反序列化的顺序必须要和序列化的顺序相同,否则会抛异常
        System.out.println(ois.readInt());
        System.out.println(ois.readBoolean());
        System.out.println(ois.readChar());
        System.out.println(ois.readDouble());
        System.out.println(ois.readUTF());
        Object dog = ois.readObject();
        System.out.println("dog运行类型:" + dog.getClass());
        System.out.println(dog);
        ois.close();

    }
}
